package com.yunxin.core.application.assembler;

import com.yunxin.core.application.command.page.AddPageCommand;
import com.yunxin.core.application.command.page.PagePageCommand;
import com.yunxin.core.application.command.page.UpdatePageCommand;
import com.yunxin.core.application.dto.page.PageListDTO;
import com.yunxin.core.application.dto.page.PagePageDTO;
import com.yunxin.core.domain.model.page.Page;
import com.yunxin.core.infra.persistence.entity.page.PageDO;
import com.yunxin.core.infra.persistence.entity.page.query.condition.PagePageCondition;
import com.yunxin.core.infra.persistence.entity.page.query.result.PageListResult;
import org.mapstruct.Mapper;

/**
 * @author zero°
 * @since 2023-05-27
 */
@Mapper(componentModel = "spring")
public interface PageAssembler {

    /**
     * result 转 dto
     * @param result result
     * @return PageListDTO
     */
    PageListDTO toPageListDTO(PageListResult result);

    /**
     * entity 转 dto
     * @param entity entity
     * @return PagePageDTO
     */
    PagePageDTO toPagePageDTO(PageDO entity);

    /**
     * command 转 entity
     * @param command command
     * @return Page
     */
    Page fromAddPageCommand(AddPageCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return Page
     */
    Page fromUpdatePageCommand(UpdatePageCommand command);

    /**
     * command 转 condition
     * @param command command
     * @return PagePageCondition
     */
    PagePageCondition fromPagePageCommand(PagePageCommand command);
}
